package com.salt.admin.api.feign.hystrix;

import com.salt.admin.api.feign.client.SystemRoleClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @Description
 * @Author salt
 * @Date 2022/4/19
 * @Version 1.0.1
 */
@Slf4j
@Component
public class SystemRoleClientHystrix implements FallbackFactory<SystemRoleClient> {

    @Override
    public SystemRoleClient create(Throwable throwable) {
        String message = throwable.getMessage() == null ?
                "No available server for client: ADMIN-CENTER" :
                throwable.getMessage();
        log.info("Hystrix:{}", message);
        return new SystemRoleClient() {
            @Override
            public Set<String> selectUserIds(Set<String> roleIds) {
                log.info("--根据ID的集合获取用户异常");
                return null;
            }
        };
    }
}
